<!-- 预约   applyparking -->
<template>
	<view>
		<view>
			<view class="block__title">预约信息</view>
			<view class="cu-form-group">
				<view class="title">姓名</view>
				{{roomDetail.appUserName}}
			</view>
			<view class="cu-form-group">
				<view class="title">房屋ID</view>
				{{roomDetail.roomId}}
			</view>
			<view class="cu-form-group">
				<view class="title">房屋编号</view>
				{{roomDetail.roomNum}}室
			</view>
			<view class="cu-form-group">
				<view class="title">楼栋</view>
				{{roomDetail.floorNum}}号楼
			</view>
			<view class="cu-form-group">
				<view class="title">单元</view>
				{{roomDetail.unitNum}}单元
			</view>
			
			
			<view class="cu-form-group">
				<view class="title">楼层</view>
				{{roomDetail.layer+'层'}}
			</view>
			<view class="cu-form-group">
				<view class="title">户型</view>
				{{roomDetail.apartment}}
			</view>
			<view class="cu-form-group">
				<view class="title">建筑面积</view>
				{{roomDetail.builtUpArea+'平方米'}}
			</view>
			
			<view class="cu-form-group">
				<view class="title">起始日期</view>
				<picker mode="date" :value="startDate" @change="startDateChange">
					<view class="picker">
						{{startDate}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">结束日期</view>
				<picker mode="date" :value="endDate" @change="endDateChange">
					<view class="picker">
						{{endDate}}
					</view>
				</picker>
			</view>
			
			<view class="bottomRegion">
				<view class="vacantHouse">
					<button @click="submitApply" type="primary">提交预约</button>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	// pages/my/myHouseDetail.js
	import context from '../../lib/java110/Java110Context.js';
	const factory = context.factory;

	export default {
		data() {
			return {
				owner:'张三',
				carNum:'',
				carBrand:'',
				carColor:'',
				communityId:'123456',
				startDate: '请选择',
				endDate: '请选择',
				delOwnerMemberFlag:false, //解除房屋绑定弹窗
				ownerInfo: {},
				// 用户信息
				userInfo: {},
				// 用户信息
				ownerFlag: false,
				// 是否有业主信息 标记 如果有为 true  没有为false
				roomDetail: {}
			};
		},

		components: {},
		props: {},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			let _that = this;
			context.onLoad(options);
			_that.roomDetail = JSON.parse(options.room);
			console.log("数据",_that.roomDetail.hometype)
		},

		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {},

		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},

		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},

		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},

		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},

		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {},
		methods: {
			// 预约起始日期
			startDateChange: function(e) {
				this.startDate = e.detail.value
			},
			// 预约结束日期
			endDateChange: function(e) {
				this.endDate = e.detail.value
			},
			loadOwenrInfo: function() {
				let _that = this;

				context.getOwner(function(_ownerInfo) {
					console.log(_ownerInfo);

					if (_ownerInfo) {
						_that.ownerFlag = true;
						_that.ownerInfo = _ownerInfo;
					} else {
						_that.ownerFlag = false;
					}
				});
			},
			vacantHouse:function(){
				wx.request({
					url: "http://localhost:8888/myhouse",
					post: "get",
					success: (ok) => {
						console.log(ok.data)
						uni.navigateTo({
							url:'./vacantHouseApplication?room='  + JSON.stringify(ok.data)
						})
					}
				})
			},
			// 提交
			submitApply:function(){
				let obj = {
					"startTime": this.startDate,
					"endTime": this.endDate,
					"communityId":this.communityId,
					"state":"1001",
					"applyPersonName":this.applyPersonName,
					"applyPersonLink":this.applyPersonLink,
					"applyPersonId":this.applyPersonId,
					"userId":this.userId
				};
				console.log(obj);
				let msg = "";
				if(obj.startTime == '2020-01-01'){
					msg = "请选择预约起始日期";
				}
				if(obj.endTime == '2020-01-01'){
					msg = "请选择预约结束日期";
				}
				if(msg != ""){
					wx.showToast({
						title: msg,
						icon: 'none',
						duration: 2000
					});
					return;
				}
				context.request({
					url: constant.url.saveOwnerCar,
					header: context.getHeaders(),
					method: "POST",
					data: obj,
					success: function(res) {
						let _json = res.data;
						if (_json.code == 0) {
							wx.redirectTo({
								url: '/pages/parkingInfo/parkingInfo',
							});
							return;
						}
						wx.showToast({
							title: "服务器异常了",
							icon: 'none',
							duration: 2000
						});
					},
					fail: function(e) {
						wx.showToast({
							title: "服务器异常了",
							icon: 'none',
							duration: 2000
						});
					}
				});
			}
		}
	};
</script>
<style scoped lang="scss">
	@import "./myHouseDetail.css";
	text {
		text-align: center;
	}
	.block__title {
		margin: 0;
		font-weight: 400;
		font-size: 14px;
		color: rgba(69, 90, 100, .6);
		padding: 40rpx 30rpx 20rpx;
	}
	.bottomRegion{
		width: 100%;
		height: 100rpx;
		position: fixed;
		bottom: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		.vacantHouse{
			margin: 20rpx;
			width: 50%;
			text-align: center;
			height: 60rpx;
			float: left;
			font-size: 26rpx;
			line-height: 60rpx;
			button{
				font-size: 26rpx;
				height: 70rpx;
				margin-top: 15rpx;
				line-height: 70rpx;
				border-radius: 40rpx 40rpx ;
			}
		}
		.removeBind{
			margin: 20rpx;
			width: 50%;
			height: 60rpx;
			float: right;
			text-align: center;
			font-size: 26rpx;
			line-height: 60rpx;
			button{
				font-size: 26rpx;
				height: 70rpx;
				margin-top: 15rpx;
				line-height: 70rpx;
				border-radius: 40rpx 40rpx ;
			}
		}
	}
</style>
